/*
	Copyright 2010-2012 Tommaso Previero
	
	This file is part of TeXdocGraphic.

	TeXdocGraphic is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.

	TeXdocGraphic is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with TeXdocGraphic.  If not, see <http://www.gnu.org/licenses/>.
	
	Created:		12/05/2012

*/

package it.texdocgraphic.gui;

import java.util.ArrayList;
import java.util.List;

public class JListTooltip {

	private List<String> details = null;	//where will be stored the details
	private List<Double> points = null;		//where will be stored the points

	/**
	 *	Default constructor for JListTooltip.
	 */
	public JListTooltip() {
		this.details = new ArrayList<String>();
		this.points = new ArrayList<Double>();
	}

	/**
	 *	Add a new Tooltip to the list.
	 *	The Tooltips are added sequentially.
	 *	If no more space left add space to manage the request.
	 *
	 *	@param detail the String that will be displayed when a mouse goes over the element
	 *	@param points the points obtained by the document
	 */
	public void addToolTip(String detail, double points) {
		this.details.add(detail);
		this.points.add(points);
	}

	/**
	 *	Empty the tooltip list.
	 */
	public void clear() {
		this.details.clear();
		this.points.clear();
	}

	/**
	 *	Return the Tooltip for the element at the index.
	 *
	 *	@param index the number representing the position of the element into the list
	 *
	 *	@return The String that was previously set for the element at the index requested.
	 */
	public String getToolTipAt(int index) {
		if(index >= 0) {
			if(index < this.details.size()) {
					if(index < this.details.size() && !"".equals(this.details.get(index))) {
						return "Points:" + this.points.get(index) + " Details:"+this.details.get(index);
					} else {
						return "Points:" + this.points.get(index) + " Details:-";
					}
			}
		}
		return null;
	}
}
